package main.Q201_300;

import java.util.ArrayList;
import java.util.List;

public class Q241_250 {
    public static void main(String[] args) {
        System.out.println("Question241：为运算表达式设计优先级");
        System.out.println("Question242：有效的字母异位词");
        System.out.println("Question243：");
        System.out.println("Question244：");
        System.out.println("Question245：");
        System.out.println("Question246：");
        System.out.println("Question247：");
        System.out.println("Question248：");
        System.out.println("Question249：");
        System.out.println("Question250：");
    }
}

class Question241{
    char[] str;
    public List<Integer> diffWaysToCompute(String s) {
        str = s.toCharArray();
        return process(0, str.length - 1);
    }
    List<Integer> process(int l, int r) {
        List<Integer> result = new ArrayList<>();
        for (int i = l; i <= r; i++) {
            if (str[i] >= '0' && str[i] <= '9') continue;
            List<Integer> l1 = process(l, i - 1), l2 = process(i + 1, r);
            for (int a : l1) {
                for (int b : l2) {
                    int cur = 0;
                    if (str[i] == '+') cur = a + b;
                    else if (str[i] == '-') cur = a - b;
                    else cur = a * b;
                    result.add(cur);
                }
            }
        }
        if (result.isEmpty()) {
            int cur = 0;
            for (int i = l; i <= r; i++) cur = cur * 10 + (str[i] - '0');
            result.add(cur);
        }
        return result;
    }
}

class Question242{
    public static boolean isAnagram(String s, String t) {
        int len = s.length();
        if(len != t.length())
            return false;
        int[] arr = new int[26];

        for(int i = 0; i < len; i++) {
            arr[s.charAt(i) - 'a']++;
            arr[t.charAt(i) - 'a']--;
        }

        for(int i = 0; i < 26; i++){
            if(arr[i] != 0)
                return false;
        }
        return true;
    }
}